/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.openbrew.openbrewrf.views;

import com.openbrew.openbrewrf.Brinks;
import com.openbrew.openbrewrf.YeastGens;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author chapmand
 */
@Entity
@Table(name = "YeastGens")
@XmlRootElement
public class YeastGensView implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "YeastGenID")
    private Integer yeastGenID;
    @Basic(optional = false)
    @NotNull
    @Column(name = "YGGeneration")
    private int yGGeneration;
    @JoinColumn(name = "YGYeastID", referencedColumnName = "YID")
    @ManyToOne(optional = false)
    private YeastView yGYeastID;
    @JoinColumn(name = "YGBrinkID", referencedColumnName = "BrinkID")
    @ManyToOne(optional = false)
    private Brinks yGBrinkID;
    @OneToMany(mappedBy = "yGPreviousYeastGen")
    private Collection<YeastGens> ygCollection;

    public YeastGensView() {
    }

    public YeastGensView(Integer yeastGenID) {
        this.yeastGenID = yeastGenID;
    }

    public YeastGensView(Integer yeastGenID, int yGGeneration) {
        this.yeastGenID = yeastGenID;
        this.yGGeneration = yGGeneration;
    }

    public Integer getYeastGenID() {
        return yeastGenID;
    }

    public void setYeastGenID(Integer yeastGenID) {
        this.yeastGenID = yeastGenID;
    }

    public int getyGGeneration() {
        return yGGeneration;
    }

    public void setyGGeneration(int yGGeneration) {
        this.yGGeneration = yGGeneration;
    }

    public YeastView getyGYeastID() {
        return yGYeastID;
    }

    public void setyGYeastID(YeastView yGYeastID) {
        this.yGYeastID = yGYeastID;
    }

    public Brinks getyGBrinkID() {
        return yGBrinkID;
    }

    public void setyGBrinkID(Brinks yGBrinkID) {
        this.yGBrinkID = yGBrinkID;
    }

    @XmlTransient
    public Collection<YeastGens> getYGCollection() {
        return ygCollection;
    }

    public void setYGCollection(Collection<YeastGens> ygCollection) {
        this.ygCollection = ygCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (yeastGenID != null ? yeastGenID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof YeastGensView)) {
            return false;
        }
        YeastGensView other = (YeastGensView) object;
        if ((this.yeastGenID == null && other.yeastGenID != null) || (this.yeastGenID != null && !this.yeastGenID.equals(other.yeastGenID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.YeastGensView[ yeastGenID=" + yeastGenID + " ]";
    }
}
